﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MeshCreater : MonoBehaviour
{
    MeshFilter meshFilter;

    LineMeshCreater meshCreater;

    List<Vector3> poss;

    Mesh mesh;

    public float Width = 1;

    public float UV_offset = 1;

    public Vector3 wordVector = Vector3.up;

    void Start()
    {
        mesh = new Mesh();
        poss = new List<Vector3>();
        meshFilter = GetComponent<MeshFilter>();
        meshCreater = new LineMeshCreater();
        meshFilter.mesh = mesh;
    }

    void Update()
    {
        poss.Clear();
        for (int i = 0; i < transform.childCount; i++)
        {
            poss.Add(transform.GetChild(i).transform.position);
        }
        meshCreater.DrawMesh(mesh, poss.ToArray(), Width, wordVector , Vector3.zero , UV_offset);
    }
}
